﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Popup.Master" AutoEventWireup="true"
    CodeBehind="ChangePassword.aspx.cs" Inherits="SapB1WebPOS.ChangePassword" %>

<asp:Content ID="Content1" ContentPlaceHolderID="PopupContent" runat="server">
    <style type="text/css">
        .forms
        {
            list-style-type: none;
            padding: 0;
            margin-bottom: -10px;
        }
        .forms label
        {
            display: inline-block;
            width: 130px;
            text-align: right;
            padding-right: 20px;
        }
        
        .forms li
        {
            margin-bottom: 10px;
        }
        
        #submitButton
        {
            width: 260px;
            margin: 10px 0 0 0;
        }
        .style1
        {
            text-align: right;
        }
    </style>
    <table border="0" style="width: 100%;">
        <tr>
            <td valign="middle" class="style1">
                New Password
            </td>
            <td>
                &nbsp;
            </td>
            <td>
                <input id="userPass" type="password" name="userPass" value="" class="k-textbox" style="width: 260px;" />
            </td>
        </tr>
          <tr style="height:5px;">
            <td align="center" valign="middle">
            </td>
            <td>
            </td>
            <td>
            </td>
        </tr>
        <tr>
            <td valign="middle" class="style1">
                Confirm Password
            </td>
            <td>
                &nbsp;
            </td>
            <td>
                <input id="confirmPass" type="password" name="userPass" value="" class="k-textbox"
                    style="width: 260px;" />
            </td>
        </tr>
       
        <tr>
            <td valign="middle" class="style1">
                &nbsp;
            </td>
            <td>
                &nbsp;
            </td>
            <td>
                <button id="submitButton" type="button" class="k-button k-button-icontext k-primary"
                    onclick="ChangePassword()">
                    Done</button>
            </td>
        </tr>
        <tr>
            <td align="center" valign="middle">
                &nbsp;
            </td>
            <td>
                &nbsp;
            </td>
            <td>
            </td>
        </tr>
        <tr>
            <td align="center" valign="middle">
                &nbsp;
            </td>
            <td>
                &nbsp;
            </td>
            <td>
                <span id="lblErrorMsg" style="color: Red; font-size: 11pt; margin-left:2px;"></span>
            </td>
        </tr>
    </table>
    <script type="text/javascript">
       
        function ChangePassword() {
            $("#lblErrorMsg").text('');
            var newPassword, confirmPassword;
            newPassword = $('#userPass').val();
            confirmPassword = $('#confirmPass').val();

            if (newPassword == '') {
                $("#lblErrorMsg").text('Please input New Password');
                return;
            }
            if (confirmPassword == '') {
                $("#lblErrorMsg").text('Please input Confirm Password');
                return;
            }
            if (newPassword != confirmPassword) {
                $("#lblErrorMsg").text('Confirm Password does not match the Password.');
                return;
            }
            $.ajax({
                type: "POST",
                url: "ChangePassword.aspx/ChangeUserPassword",
                data: JSON.stringify({
                    newPassword: newPassword
                }),
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (data) {
                    if (data.d != "SUCCESS") {
                        $("#lblErrorMsg").text(data.d);
                    }
                    else {
                        parent.$("#changePass").data("kendoWindow").close();
                    }
                },
                error: function (xhr, status, err) {
                    alert(err.Message);
                }
            });
        }
    </script>
</asp:Content>
